#include <REGX51.H>
sbit led1 = P2^0;
sbit Button1 = P3^1;
//定时
void Delay(unsigned int timerNum)
{
	unsigned char i, j;
	while(timerNum--)
	{
		i = 2;
		j = 109;
		do
		{
			while (--j);
		} while (--i);
	}
}
//点击button1
void click()
{
		if (Button1 == 0)
		{
			Delay(500);
			led1 = 0;
			Delay(500);
			led1 = 1;
		}
		else if(Button1 == 1)
		{
			led1 = 1;
		}
}
void main()
{
	while(1)
	{
		click();
	}
}